<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>找回密码</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link href="${ctx }/css/style.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="${ctx }/js/jquery/jquery-1.6.1.min.js"></script>
		<script type="text/javascript">
			$(function() {
				var url = "${ctx}/user/findPassword.action";
				
				$("#btnSureId").click(function() {
					var param = { "step": "1", "username": $("#username").val() };

					$.post(url, param, function(returnData) {
						if ("" != returnData.msg) {
							alert(returnData.msg);
						} else {
							$("#btnSureId").attr("disabled", "disabled");
							$("#divAnswer").css("display", "block");
						}
					});
				});

				$("#btnSureAnswer").click(function() {
					var param = { "step": "2", "username": $("#username").val(), "question": $("#question").val(), "answer": $("#answer").val() };

					$.post(url, param, function(returnData) {
						if ("" != returnData.msg) {
							alert(returnData.msg);
						} else {
							$("#btnSureAnswer").attr("disabled", "disabled");
							$("#btnReset").attr("disabled", "disabled");
							$("#divPass").css("display", "block");
						}
					});
				});

				$("#btnReset").click(function() {
					$("#question").val("");
					$("#answer").val("");
				});

				$("#btnNewPass").click(function() {
					var param = { "step": "3", "username": $("#username").val(), "password": $("#newPassword").val() };

					$.post(url, param, function(returnData) {
						if (!"success" == returnData.msg) {
							alert(returnData.msg);
						} else {
							alert("恭喜您，重新设置密码成功，请牢记！");
							self.close();
						}
					});
				});
			});
		</script>
	</head>
	<body style="text-align: center;">
		<div style="width: 50%" align="center">
			<div id="divUsername" style="text-align: center; margin: 0 auto; border: 1px solid blue">
				请输入登陆名：
				<s:textfield id="username" cssClass="td1" cssStyle="width: 162px; height: 29px"></s:textfield>
				<br />
				<br />
				<input type="button" value="提交" class="botton"
					style="cursor: hand; width: 70px; height: 24px;" id="btnSureId" />
				<br />
				<br />
			</div>
			<br />
			<br />
			<div id="divAnswer" style="text-align: center; margin: 0 auto; display: none; border: 1px solid blue">
				问题：
				<s:textfield id="question" cssClass="td1" cssStyle="width: 170px; height: 30px"></s:textfield>
				<br />
				<br />
				答案：
				<s:textfield id="answer" cssClass="td1" cssStyle="width: 172px; height: 33px"></s:textfield>
				<br />
				<br />
				<input  type="button" value="提交" class="botton"
					style="cursor: hand; width: 64px; height: 24px;" id="btnSureAnswer" />
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" value="重写" class="botton" style="cursor: hand; width: 68px; height: 22px;" id="btnReset" />
				<br />
				<br />
			</div>
			<br />
			<br />
			<div id="divPass" style="text-align: center; margin: 0 auto; display: none; border: 1px solid blue">
				&nbsp; &nbsp; &nbsp;&nbsp; 输入新密码：
				<s:password id="newPassword" cssClass="td1" cssStyle="width: 166px; height: 33px"></s:password>
				&nbsp;&nbsp;&nbsp;
				<br />
				<br />
				&nbsp; &nbsp; &nbsp; 确认新密码：
				<s:password id="surePassword" cssClass="td1" cssStyle="width: 166px; height: 31px"></s:password>
				&nbsp;&nbsp;&nbsp;
				<br />
				<br />
				<input  type="button" value="提交"style="cursor: hand; width: 64px; height: 24px;" id="btnNewPass" />
			</div>
		</div>
	</body>
</html>
